<input type="hidden" id="ticketId" name="ticketId" value="{$ticketId}">
<!-- Ticket name -->
<div class="field-row">
    <span id="openTicketName" class="strong">{$ticketName}</span>
</div>

<!-- View div -->
<div id="commonInfoView" style="display: block;">
 <div class="field-row">
     <div class="field-label" style="width: 130px;">{translate}Examination type{/translate}</div>
     <div class="field-value" style="width: 180px;"><span class="field" style="text-transform: uppercase;">{$examinationType}</span></div>
     <div class="field-label" style="width: 130px;">{translate}Promotion program_1{/translate}</div>
     <div class="field-value"><span class="field">{if !empty($discountProgram)}{$discountProgram}{else}N/A{/if}</span></div>
     <div style="clear: both;"></div>
 </div>
 {foreach from=$insInfoList item=insInfo}
 {if $insInfo->getInsuranceGroup()}
 <div id="insuranceInfo">
     <div class="field-row">
         <div class="field-label" style="width: 130px;">{translate}Health insurance No.{/translate}</div>
         <div class="field-value" style="width: 180px;"><span class="field">{$insInfo->getInsuranceNumber()}</span></div>
         <div class="field-label" style="width: 130px;">{translate}Usage time{/translate}</div>
         <div class="field-value"><span class="field">{$insInfo->getIssuedDate(true)} - {$insInfo->getExpiredDate(true)}</span></div>
         <div class="field-value" style="padding-left: 20px;">
             <input type="checkbox" name="correctRoute" id="correctRoute" value="" readonly="readonly" {if $insInfo->isCorrectInsuranceRoute()}checked="checked"{/if} disabled="disabled">
             <span class="label"><label for="correctRoute">{translate}Correct route{/translate}</label></span>
         </div>
         <div class="field-value" style="padding-left: 20px;">
             <input type="checkbox" name="paidFor36Month" id="paidFor36Month" disabled="disabled" {if ($insInfo->getPaidFor36Month() > 0)}checked="checked"{/if}>
             <span class="label"><label for="paidFor36Month">{translate}Paid for 36 months{/translate}</label></span>
         </div>
         <div style="clear: both;"></div>
     </div>
     <div style="display: none;">{$cardNumber++}</div>
 </div>
 {/if}
 {/foreach}
 <div style="text-align: right; margin-top: 10px;">
        <input type="button" style="width: 60px;" value="{translate}Edit{/translate}" onclick="switchDiv('commonInfoView', 'commonInfoEdit');">
 </div>
</div>

<!-- Edit div -->
<div id="commonInfoEdit" style="display: none;">
    <div style="float: right; display: none;" id="updateCommonDiv">
        <img src="images/ajax-loader.gif"/> 
    </div>
    <div style="padding-top: 5px;"><span id="ticketCommonInfoMsg" class="formAlertMsg" style="display: none;"></span></div>
    <div class="field-row" style="padding-top: 5px;">
	     <div class="field-label" style="width: 130px; vertical-align: top;">{translate}Examination type{/translate}</div>
	     <div class="field-value" style="width: 200px;">
             <select id="examinationTypeLbx" style="width: 160px;" onchange="checkInsuranceType()">
	                {html_options options=$examinationTypeList selected=$enumExaminationType}
	         </select>&nbsp;           
	     </div>
	     <div class="field-label" style="width: 110px;">{translate}Promotion program_1{/translate}</div>
	     <div class="field-value" style="width: 300px;">
	         <select id="discountProgramLbx" style="width: 250px;">
	              <option value="0" label="- - -">- - -</option>
	             {html_options options=$discountList selected=$discountProgram}
	         </select>&nbsp;
	     </div>
    </div>
    
    <div id="insuranceCardInfo" {if ($enumExaminationType != $insuranceType)}style="display: none"{/if}>
	    <div class="field-row" style="margin-top: 5px;">
	        <div class="field-label" style="width: 130px;">{translate}MI card{/translate}</div>
	        <div class="field-value">
	            <select id="insuranceCardLbx" style="width: 300px;">
	                <option value="" label="- - -">- - -</option>
	                {foreach from=$insuranceCardList item=item}
	                    <option value="{$item.insurance_id}" label="{$item.insurance_code}&nbsp;&nbsp;&nbsp;&nbsp;{$item.date_issued}-{$item.date_expired}" hospital_name="{$item.hospital_name}" date_issued="{$item.date_issued}" date_expired="{$item.date_expired}" insurance_code={$item.insurance_code}>{$item.insurance_code}&nbsp;&nbsp;&nbsp;&nbsp;{$item.date_issued}-{$item.date_expired}</option>
	                {/foreach}
	            </select>&nbsp;
	        </div>
	        <div style="padding-left: 10px;" class="field-value">
	            <button id="addTicketInsuranceBtn" onclick="addTicketInsurance()">{translate}Select{/translate}</button>&nbsp;
	        </div>
	        <div class="field-value" style="padding-left: 10px;">
	            <button id="addInsuranceBtn" onclick="addPatientInsurance()">{translate}Add new MI card{/translate}</button>&nbsp;
	        </div>                    
	        <div style="clear: both;"></div>
	    </div>
	    <div style="margin-top: 10px;">
	        <table id="insuranceCardTbl" style="width: 100%;" class="grid" cellpadding="0" cellspacing="0">                
	            <thead>
	                <tr>
                        <th style="width: 170px;">{translate}Health insurance No.{/translate}</th>
                        <th style="width: 190px;">{translate}Usage time{/translate}</th>
                        <th>{translate}Registered hospital{/translate}</th>
                        <th style="width: 200px;">{translate}Additional infomation{/translate}</th>
                        <th style="width: 60px;">&nbsp;</th>
                    </tr>
	            </thead>
	            <tbody>
	                {if !empty($insInfoList)}
	                {foreach from=$insInfoList item=item}
	                
	                    <tr id="{$item->getInsuranceId()}">
                           <td>
                               <div class="field-value">
                                 <a href="javascript:editInsurance({$item->getInsuranceId()})" title="{translate}Edit medical insurance card info{/translate}">{$item->getInsuranceNumber()}</a>
                               </div>
                           </td>
                           <td>
                                <div class="field-value">{$item->getIssuedDate(true)} - {$item->getExpiredDate(true)}</div>
                           </td>
                           <td>
                                <div class="field-value">
                                   {$item->getRegisteredHospital()}
                                </div>
	                       </td>
	                       <td>
	                            <div class="field-row">
	                                <div class="field-value">
	                                    <input type="checkbox" name="correctRoute" id="correctRoute" {if $item->isCorrectInsuranceRoute()}checked="checked"{/if}>
	                                    <label for="correctRoute">{translate}Correct route{/translate}</label>
	                                </div>
	                                <div style="clear: both;">
	                            </div>
                            <div class="field-row">
								<div class="field-value">
									 <input type="checkbox" name="paidFor36Month" id="paidFor36Month" {if ($item->getPaidFor36Month() > 0)}checked="checked"{/if}>
									 <label for="paidFor36Month">{translate}Paid for 36 months{/translate}</label>
								</div>
                           </div>
	                     </td>
	                     <td class="action" style="vertical-align: middle;">
	                            <a href="javascript:removeInsuranceItem({$item->getInsuranceId()})" title="{translate}Remove{/translate}"><img src="images/remove.png"></a>
	                     </td>
                    </tr>        
	                
	                {/foreach}
	                {else}
	                <tr class="last" id="noResult"><td colspan="5">{translate}The ticket has not used medical insurance cards{/translate}</td></tr>
	                {/if}
	            </tbody>
	        </table>
	    </div>
    </div>
    
    <div style="text-align: right; margin-top: 10px;">
        <input type="button" style="width: 60px;" value="{translate}Save{/translate}" onclick="updateTicketCommon();">
        <input type="button" style="width: 60px;" value="{translate}Cancel{/translate}" onclick="switchDiv('commonInfoView', 'commonInfoEdit');">
    </div>
</div>

<!-- Add insurance -->
<div style="display: none;" id="addInsuranceDiv">
    {include file="insurance/general_insurance_add.html"}
</div>
